import java.io.Serializable;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.ObjectOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
class Student implements Serializable
	{
	String name;
	String address;
	int roll;
	double score;
	
	public static void Serialize(ObjectOutputStream oos, Student s)
		{
			oos.writeObject(s);
		}
	
	void Deserialize()
		{
		Student s[] = new Student[3];
		try
			{
			FileInputStream fis = new FileInputStream("student.ser");
			ObjectInputStream ois1 = new ObjectInputStream(fis);
			s[0] = (Student) ois1.readObject();
			ObjectInputStream ois2 = new ObjectInputStream(fis);
			s[1] = (Student) ois2.readObject();
			ObjectInputStream ois3 = new ObjectInputStream(fis);
			s[2] = (Student) ois3.readObject();
			ois1.close();
			ois2.close();
			ois3.close();
			fis.close();
			}
		catch(IOException ioe)
			{
			ioe.printStackTrace();
			return;
			}
		catch(ClassNotFoundException cnfe)
			{
			System.out.println("Student Class Not Found");
			cnfe.printStackTrace();
			return;
			}
		showStudent(s[0]);
		showStudent(s[1]);
		showStudent(s[2]);
		}
	void showStudent(Student s)
		{
		System.out.println("Student Details.....");
		System.out.println("Name : " + s.name);
		System.out.println("Address : " + s.address);
		System.out.println("Roll : " + s.roll);
		System.out.println("Score : " + s.score);
		}
	}
	
class Serialize3Object
	{
	public static void main(String args[])
		{
		Student s1 = new Student();
		Student s2 = new Student();
		Student s3 = new Student();
		
		s1.name = "Rajiv";
		s1.address = "Bangalore";
		s1.roll = 1;
		s1.score = 99.32;
		
		s2.name = "Sanjeev";
		s2.address = "Bangalore";
		s2.roll = 2;
		s2.score = 98.32;
		
		s3.name = "Pulkit";
		s3.address = "Bangalore";
		s3.roll = 3;
		s3.score = 94.32;
		
		try
			{
			FileOutputStream fos = new FileOutputStream("student.ser");
			ObjectOutputStream oos = new ObjectOutputStream(fos);
			oos.writeObject(s1);
			oos.writeObject(s2);
			oos.writeObject(s3);
			oos.close();
			fos.close();
			}
		catch(IOException ioe)
			{
			
			}
		
		s1.Deserialize();
		s2.Deserialize();
		s3.Deserialize();
		}
	}
